Context menu for project (bug#69566)
authorJuri Linkov <juri@linkov.net>
Thu, 14 Mar 2024 17:29:16 +0000 (19:29 +0200)
committerJuri Linkov <juri@linkov.net>
Thu, 14 Mar 2024 17:29:16 +0000 (19:29 +0200)
* lisp/menu-bar.el (menu-bar-project-item): New variable from
'project-menu-entry'.
(menu-bar-tools-menu): Use 'menu-bar-project-item'.

* lisp/mouse.el (context-menu-functions): Add
'context-menu-project' to choice.
(context-menu-project): New function.

* lisp/progmodes/project.el (project-menu-entry): Remove variable.
(project-mode-line-map): Use 'menu-bar-project-item' instead of
'project-menu-entry'.

lisp/menu-bar.el
lisp/mouse.el
lisp/progmodes/project.el

index 5b290899ff5a4e97698acbefb872c58848077341..320fabb54cf858b9169581c01436317284e164c2 100644 (file)
@@ -1838,6 +1838,9 @@ mail status in mode line"))
     (bindings--define-key menu [project-open-file] '(menu-item "Open File..." project-find-file :help "Open an existing file that belongs to current project"))
     menu))
 
+(defvar menu-bar-project-item
+  `(menu-item "Project" ,menu-bar-project-menu))
+
 (defun menu-bar-read-mail ()
   "Read mail using `read-mail-command'."
   (interactive)
@@ -1925,7 +1928,7 @@ mail status in mode line"))
                   :help "Start language server suitable for this buffer's major-mode"))
 
     (bindings--define-key menu [project]
-      `(menu-item "Project" ,menu-bar-project-menu))
+      menu-bar-project-item)
 
     (bindings--define-key menu [ede]
       '(menu-item "Project Support (EDE)"
index 26835437c08215d74d822cd3d2c81be59c602b18..cef88dede8a4f10bf9bce2e3abb3d89d710b35c5 100644 (file)
@@ -393,6 +393,7 @@ and should return the same menu with changes such as added new menu items."
                   (function-item context-menu-local)
                   (function-item context-menu-minor)
                   (function-item context-menu-buffers)
+                  (function-item context-menu-project)
                   (function-item context-menu-vc)
                   (function-item context-menu-ffap)
                   (function-item hi-lock-context-menu)
@@ -533,6 +534,12 @@ Some context functions add menu items below the separator."
               (mouse-buffer-menu-keymap))
   menu)
 
+(defun context-menu-project (menu _click)
+  "Populate MENU with project commands."
+  (define-key-after menu [separator-project] menu-bar-separator)
+  (define-key-after menu [project-menu] menu-bar-project-item)
+  menu)
+
 (defun context-menu-vc (menu _click)
   "Populate MENU with Version Control commands."
   (define-key-after menu [separator-vc] menu-bar-separator)
index 9622b1b6768f8ca2a7db33f0947411945f0f09c8..4284ea6edc63a7da9b73eb776eccbdeba86473fa 100644 (file)
@@ -2140,12 +2140,10 @@ is part of the default mode line beginning with Emacs 30."
   :group 'project
   :version "30.1")
 
-(defvar project-menu-entry
-  `(menu-item "Project" ,(bound-and-true-p menu-bar-project-menu)))
-
 (defvar project-mode-line-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [mode-line down-mouse-1] project-menu-entry)
+    (define-key map [mode-line down-mouse-1]
+                (bound-and-true-p menu-bar-project-item))
     map))
 
 (defvar project-mode-line-face nil